local STool = {}

CatmullRomCams.SToolMethods.LightCrafter  = STool

function STool.LeftClick(self, trace)

	local thisPlayer = self:GetOwner()
	
	local lightFrame = ents.Create("sent_lightframe")
	
	if not (lightFrame and lightFrame:IsValid()) then return end
	
	lightFrame:SetPos(trace.HitPos)
	lightFrame:Spawn()

	lightFrame.UndoData = {}
	lightFrame.UndoData.PID = plyID
	lightFrame.UndoData.Key = key
	lightFrame.UndoData.TrackIndex = track_index
	
	undo.Create("LightFrame")
	undo.AddEntity(lightFrame)
		
	undo.SetPlayer(thisPlayer)
	undo.Finish()
	
	thisPlayer:AddCleanup("catmullrom_cameras", lightFrame)
	
end

function STool.RightClick(self, trace)

	if SERVER then
		if(trace.Entity) then

			local traceEntity = trace.Entity
			local thisPlayer = self:GetOwner()
	
			if(traceEntity:GetClass() == "sent_lightframe") then
				traceEntity:InvokeProperties(thisPlayer)
			end

		end
	end
	
end

function STool.Reload(self, trace)

end

function STool.Think(self)

end

function STool.BuildCPanel(panel)
	--panel:AddControl("Header", {Text = "Catmull-Rom Cinematic Cameras: Track Layout Creator", Description = "Use this to create your track's layout!"})
	
	panel:AddControl("Numpad",   {Label = "Track Trigger Key: ", Command = "catmullrom_camera_key", ButtonSize = 22})
	
	panel:AddControl("Slider",   {Label = "Bank Delta: ",         Description = "(Change Speed Max) How fast is the maximum we should be able to bank in one frame? (1 = As much as we want.)", Type = "Float", Min = "0.01", Max = "1", Command = "catmullrom_camera_bankdelta_max"})
	panel:AddControl("Slider",   {Label = "Bank Multiplier: ",    Description = "(Magnify Banking Effect) How much should we multiply the amount we bank in one frame? (1 = No change.)",       Type = "Float", Min = "0.01", Max = "5", Command = "catmullrom_camera_bank_multi"})
	
	panel:AddControl("Slider",   {Label = "Zoom: ", Description = "Default is 75. Press 'USE' (typically 'e' on your keyboard) to reset Zoom & Roll.", Type = "Float", Min = ".1", Max = "170",   Command = "catmullrom_camera_zoom"})
	
	panel:AddControl("Slider",   {Label = "Roll: ",        Description = "DO A BARREL ROLL! Beware! Make sure you add a node with '0' if you just want to make part of the track rolling;\nOtherwise the camera will jump!", Type = "Float", Min = "-180", Max = "180", Command = "catmullrom_camera_roll"})
	
	--panel:AddControl("CheckBox", {Label = "Don't Stop At Track End: ", Description = "(Requires to be on Control node.) Just stay at the last position at the end of the track.", Command = "catmullrom_camera_enable_stay_on_end"})
	--panel:AddControl("CheckBox", {Label = "Loop Track: ",              Description = "(Requires to be on Control node & that the option above is on.) But loop instead.", Command = "catmullrom_camera_enable_looping"})
end
